<?php
session_start();
include_once "checkLogin.php";
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="css/menu.css" rel="stylesheet" type="text/css"/>
    <script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="js/nav.js" type="text/javascript"></script>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="js/TweenMax.min.js"></script>
    <link href="css/word.css" rel="stylesheet" type="text/css"/>
    <title>图书馆信息</title>
    <style>
        .layui-form {
            width: 50%;
            margin: 3% auto;
        }

        #now {
            margin-left: 5%;
            margin-top: 1%;
        }
    </style>
</head>
<body>
<canvas id="Mycanvas" style="position: absolute;left: 0%;width: 100%;height: 99%"></canvas>
<div id="main">
    <header>
        <div id="header1">
            <div id="a"></div>
            <img src="img/logo1.png">
            <h2 class="letter-wrap"  data-stagger="-0.015">清华大学图书馆管理系统</h2>
            <span>当前登录用户：<?php echo $_SESSION['admin']?></span>
        </div>
    </header>
    <div class="navmain">
        <div id="time"><span></span></div>
        <ul id="nav_all">
            <li><a href="index.php">首页</a></li>
            <?php
            include_once "conn.php";
            $main = new main();
            $info = $main->checkAdmin($_SESSION['admin']);
            if ($info['system']){
                ?>
                <li><a href="#">系统设置</a>
                    <ul style="display: none;">
                        <li><a href="library.php">图书馆信息</a></li>
                        <li><a href="admin.php">管理员设置</a></li>
                        <li><a href="#">参数设置</a></li>
                        <li><a href="shujia.php">书架设置</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['readerset']){
                ?>
                <li><a href="#">读者管理</a>
                    <ul style="display: none;">
                        <li><a href="readertype.php">读者类型管理</a></li>
                        <li><a href="user.php">读者档案管理</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['bookset']){
                ?>
                <li><a href="tushudangan.php">图书档案管理</a></li>
                <?php
            }
            if ($info['book']){
                ?>
                <li><a>图书借还</a>
                    <ul style="display: none;">
                        <li><a href="bookjieyue.php">图书借阅</a></li>
                        <li><a href="bookxujie.php">图书续借</a></li>
                        <li><a href="bookback.php">图书归还</a></li>
                    </ul>
                </li>
                <?php
            }
            if ($info['syschaxun']){
                ?>
                <li> <a>系统查询</a>
                    <ul style="display: none;">
                        <li><a href="tushudanganchaxun.php">图书档案查询</a></li>
                        <li><a href="jieyuechaxun.php">图书借阅查询</a></li>
                        <li><a href="jieyue.php">借阅到期提醒</a></li>
                    </ul>
                </li>
                <?php
            }
            ?>
            <li>
                <a href="pw.php">更改口令</a>
            </li>
            <li><a href="zhuxiao.php">注销</a> </li>
        </ul>
    </div>
    <div id="b"></div>
    <div id="c">
        <?php
        include_once "conn.php";
        $main = new main();
        $info = $main->libraryinfo();
        ?>
        <div id="now">当前位置：系统设置 > 图书馆信息 >>></div>
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">图书馆名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required lay-verify="required" value="<?php echo $info['name'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">馆长</label>
                <div class="layui-input-inline">
                    <input type="text" name="boss" required lay-verify="required" value="<?php echo $info['boss'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" required lay-verify="required" value="<?php echo $info['phone'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系地址</label>
                <div class="layui-input-block">
                    <input type="text" name="dizhi" required lay-verify="required" value="<?php echo $info['dizhi'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">E-mail</label>
                <div class="layui-input-inline">
                    <input type="email" name="mail" required lay-verify="required" value="<?php echo $info['mail'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图书馆网址</label>
                <div class="layui-input-inline">
                    <input type="text" name="url" required lay-verify="required" value="<?php echo $info['url'] ?>"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">建馆时间</label>
                    <div class="layui-input-inline">
                        <input type="text" name="time" required lay-verify="required" class="layui-input" id="test19" autocomplete="off" value="<?php echo date('Y-m-d',$info['careatdate']) ?>">
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">图书馆简介</label>
                <div class="layui-input-block">
                    <textarea name="desc"  class="layui-textarea"> <?php echo $info['jianjie'] ?></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button id="btn" class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="history.back();">取消</button>
                </div>
            </div>
        </form>
    </div>
    <footer>
        <hr id="one">
        <hr id="two">
        CopyRight © 2019 www.cdp.cn.com 清华大学图书馆
    </footer>
</div>
</body>
<script src="layui/layui.js"></script>
<script src="js/bg.js"></script>
<script src="js/logo.js"></script>
<script>
    //Demo
    layui.use(['form', 'laydate'], function () {
        var form = layui.form,
            laydate = layui.laydate;
        laydate.render({
            elem: '#test19'
            ,value: $("#test19").val()
            ,isInitValue: true
        });
        //监听提交
        form.on('submit(formDemo)', function (data) {
            console.log(data.field);//当前容器的全部表单字段，名值对形式：{name: value}
            $(function () {
                $.ajax({
                    type: "POST",
                    url: "libraryinfo.php",
                    data: {
                        name: data.field.name,
                        boss: data.field.boss,
                        phone: data.field.phone,
                        dizhi: data.field.dizhi,
                        mail: data.field.mail,
                        url: data.field.url,
                        time: data.field.time,
                        desc: data.field.desc
                    },
                    dataType: 'JSON',
                    cache: false, //不缓存此页面
                    success: function (data) {
                        console.log(data);
                        if (data.error === 1) {
                            layer.msg('保存成功!');
                            setTimeout(function () {
                                window.location.reload();
                            },500);
                        } else {
                            layer.msg('保存失败!请重试!');
                        }
                    }
                })
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>
</html>